Skip to content

Add worker-based Typst source export#96

Closed
Copilot wants to merge 17 commits into
devfrom
copilot/export-as-typst-source
Closed

Add worker-based Typst source export#96
Copilot wants to merge 17 commits into
devfrom
copilot/export-as-typst-source

Conversation

Copilot AI commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Adds a Typst source export flow that packages template sources, generated .typ files, assets, and config into a downloadable zip, with the heavy compile/zip work executed inside the Typst worker.

Changes Made

  • Build the Typst export archive in the compiler worker for better isolation and performance.
  • Preserve the “导出为 typst 源码” menu entry and update it to call the worker-backed exporter.
  • Harden asset mapping, file extension resolution, and missing-image error messages for export.
  • Keep a dedicated export helper module that delegates to the worker.

Testing

  • npm run lint
  • npm run test
  • npm run build

UI

Screenshot: https://github.com/user-attachments/assets/da202edf-55e0-40c6-b6ea-67f44943a24e

Original prompt

This section details on the original issue you should resolve

<issue_title>导出为 typst 源码</issue_title>
<issue_description>有时候可能需要对 pdf 进行深度修改,比如将 测试点数目 改称 子任务数目。导出为 typst 源码可以方便进行客制化修改

虽然关掉 NOI 模式可以改成子任务数目,但有可能我即想要文件夹子目录又想要绑包</issue_description>

<agent_instructions>实现导出为 typst 源码功能。
功能入口位于菜单栏的“文件”下,添加一个“导出为 typst 源码”的菜单项。
点击按钮后,将整个项目导出为一个压缩包,里面包含了 typst 源码,config.json 以及相关静态文件。导出后的压缩包应当可以直接编译。</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@Mr-Python-in-China Image

可以做,不过导出出来的东西基本完全不可读,我只考虑了编译器能识别</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Feb 2, 2026

Copy link
Copy Markdown

Deploying cnoi-statement-generator with  Cloudflare Pages  Cloudflare Pages

Latest commit: 50f2712
Status: ✅  Deploy successful!
Preview URL: https://0ed9312d.cnoi-statement-generator.pages.dev
Branch Preview URL: https://copilot-export-as-typst-sour.cnoi-statement-generator.pages.dev

View logs

Copilot AI changed the title [WIP] Add export as typst source feature Add editor export for Typst source archive Feb 2, 2026

@Mr-Python-in-China Mr-Python-in-China left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 把exportTypstArchive相关逻辑移动到一个新文件中以方便管理

Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>

Copilot AI commented Feb 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot 把exportTypstArchive相关逻辑移动到一个新文件中以方便管理

已将 exportTypstArchive 相关逻辑移动到 src/utils/exportTypstArchive.ts,并更新调用处。提交:7fdc524。截图: https://github.com/user-attachments/assets/4555d0c7-f4be-4a58-bb9e-c8c801fe74a6

Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>

@Mr-Python-in-China Mr-Python-in-China left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 把编译和打包成zip的逻辑做到 worker 中

Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>

Copilot AI commented Feb 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot 把编译和打包成zip的逻辑做到 worker 中

已将编译与打包 zip 的逻辑迁移到 compiler worker,并在主线程通过 worker 生成压缩包。提交:e165dfc。截图:https://github.com/user-attachments/assets/da202edf-55e0-40c6-b6ea-67f44943a24e

Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>

@Mr-Python-in-China Mr-Python-in-China left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 提到一个单独的模块,然后在worker中动态导入以减少网络请求

Copilot AI and others added 8 commits February 3, 2026 11:06
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Copilot AI and others added 3 commits February 3, 2026 11:24
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Co-authored-by: Mr-Python-in-China <89737170+Mr-Python-in-China@users.noreply.github.com>
Copilot AI changed the title Add editor export for Typst source archive Add worker-based Typst source export Feb 3, 2026
@Mr-Python-in-China Mr-Python-in-China deleted the copilot/export-as-typst-source branch February 3, 2026 11:38
Copilot stopped work on behalf of Mr-Python-in-China due to an error February 3, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants